package net.startingpoint;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;

import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class PathOverlay extends Overlay {

	private UserLocation mUserLocation;
	private UserLocation mDestLocation;

	public PathOverlay() {
	}

	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {
		
		if(mUserLocation != null && mDestLocation != null) {
			Paint paint = new Paint();
			Point screenCoords = new Point();
			Point screenCoords1 = new Point();

			mapView.getProjection().toPixels(mUserLocation.GEO_POINT, screenCoords);
			int x1 = screenCoords.x;
			int y1 = screenCoords.y;

			mapView.getProjection().toPixels(mDestLocation.GEO_POINT, screenCoords1);
			int x2 = screenCoords1.x;
			int y2 = screenCoords1.y;

			paint.setStrokeWidth(2);
			canvas.drawLine(x1, y1, x2, y2, paint);
			super.draw(canvas, mapView, shadow);
		}
	}
	
	public void setDestLocation(UserLocation p) {
		mDestLocation = p;
		
	}
	
	public void setUserLocation(UserLocation p) {
		mUserLocation = p;
	}
	
	public UserLocation getUserLocation() {
		return mUserLocation;
	}
	
	public UserLocation getDestLocation() {
		return mDestLocation;
	}

}
